#ifndef QGRID
#define QGRID

#include <QtGui>

#include "grid.h"

/* 
 * Initialize this with pointer to the mothership Grid
 * From mothership, receive position and spacing of the grid
 * Draw a bunch of squares
 *
 * Click turns square on
 * RClick turns square off
 * ^Click+Drag moves the grid
 * ^Click+Drag corners resizes the grid
 */

class qGrid : public QWidget
{
    Q_OBJECT

    public:
        qGrid();
        qGrid(QWidget *parent, Grid *grid);

    signals:
        void gridMove();

    public slots:
        void highlightEdges(bool highlight);
        void clear();

    protected:
        void mousePressEvent(QMouseEvent *event);
        void mouseMoveEvent(QMouseEvent *event);
        void mouseReleaseEvent(QMouseEvent *event);
        void paintEvent(QPaintEvent *event);

    private:
        int resizeMode;

        Grid *mothership;

        int* coord2square(int x, int y);

        int fillColor;

        QPoint oldMousePos;
        QPoint oldGridPos;
        int oldWidth;
        int oldHeight;
};

#endif
